<template>
  <!-- 对话框：定义标题动态绑定；控制对话框显隐，双向绑定；对话框宽度；关闭时销毁对话框实例；点击模态框不关闭对话框 -->
  <el-dialog
    :title="title"
    :visible.sync="openSheet"
    width="50%"
    :destroy-on-close="true"
    :close-on-click-modal="false"
  >
    <!-- 表单组件 -->
    <el-form ref="form" :model="form" disabled :label-width="labelWidth">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('standardCurrency')">
            <el-input
              v-model="form.standard_curr"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('quoteCurrency')">
            <el-input
              v-model="form.quote_curr"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('rateDate')">
            <el-input
              v-model="form.rate_date"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('rate')">
            <el-input
              v-model="form.exchange_rate"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">{{ $t('cancel') }}</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  // 数据定义
  data() {
    return {
      title: undefined,
      openSheet: false, // 对话框显示
      form: {} // 表单数据（接收父组件传入对象）
    };
  },
  computed: {
    labelWidth() {
      return this.$i18n.locale === 'en' ? '150px' : '80px';
    }
  },
  methods: {
    async openSheetDialog(data) {
      this.openSheet = !this.openSheet; // 显示对话框
      this.title = this.$t('serialNumberInquireTitle'); // 设置标题
      this.form = data; // 将父组件传入的数据赋值给表单
    },
    cancel() {
      this.openSheet = !this.openSheet; // 关闭对话框
    }
  }
};
</script>

<style scoped>
.el-input input, .table-select .el-input__inner {
  width: 220px;
  box-sizing: border-box;
}
::v-deep .el-form-item__label {
    text-align: right;
}
</style>

